package com.example.springbootdemo.controller;


import com.example.springbootdemo.utils.WebResult;

public class BaseController {
    protected WebResult ok() {
        return WebResult.ok(null);
    }
    protected WebResult ok(String msg) {
        return WebResult.ok(msg,null);
    }
    protected WebResult ok(boolean b) {
        if (b){
            return ok("成功");
        }else {
            return fail("失败");
        }
    }

    protected WebResult ok(String msg, Object data) {
        return WebResult.ok(msg, data);
    }

    protected WebResult data(Object data) {
        return WebResult.ok(data);
    }

    protected WebResult bool(boolean data) {
        return WebResult.ok("成功",data);
    }

    protected WebResult fail(int code, String msg) {
        return WebResult.fail(code, msg);
    }
    protected WebResult fail() {
        return WebResult.fail(1, "request error");
    }
    protected WebResult stop() {
        return WebResult.fail(20, "request stop");
    }

    protected WebResult fail(String msg) {
        return WebResult.fail(1, msg);
    }

}
